//
//  LYQMineTopicMangeViewController.m
//  ZCProject
//
//  Created by Zheng on 16/12/5.
//  Copyright © 2016年 Zheng. All rights reserved.
//

#import "LYQMineTopicMangeViewController.h"

#import "LYQMineTopicManageCell.h"
#import "LYQMineTopicManageNumberCell.h"

#define kLYQMineTopicManageCell_ID @"kLYQMineTopicManageCell_ID"
#define kLYQMineTopicManageNumberCell_ID @"kLYQMineTopicManageNumberCell_ID"

@interface LYQMineTopicMangeViewController () <UITableViewDelegate,UITableViewDataSource>

@end

@implementation LYQMineTopicMangeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"话题管理";
    
    self.listTableView.delegate = self;
    self.listTableView.dataSource = self;
    self.listTableView.estimatedRowHeight = 100;
    self.listTableView.rowHeight = UITableViewAutomaticDimension;
    [self.listTableView registerNib:[UINib nibWithNibName:@"LYQMineTopicManageCell" bundle:nil] forCellReuseIdentifier:kLYQMineTopicManageCell_ID];
    [self.listTableView registerClass:[LYQMineTopicManageNumberCell class] forCellReuseIdentifier:kLYQMineTopicManageNumberCell_ID];
    
}

#pragma mark - tableview datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0) {
        
        LYQMineTopicManageCell *cell = [tableView dequeueReusableCellWithIdentifier:kLYQMineTopicManageCell_ID forIndexPath:indexPath];
        
        if (indexPath.section == 0) {
            cell.infoLbl.text = @"按实际的拉伸觉得快拉丝机的卢卡斯建档立卡见识到了就爱上了肯德基";
        } else {
            cell.infoLbl.text = @"啊掉身价库拉索建档立卡手机登录卡机了的开始就爱上了肯德基阿拉斯加的老卡机的考拉手机登录卡斯加达拉斯建档立卡就是";
        }
        
        return cell;
    } else {
        
        LYQMineTopicManageNumberCell *cell = [tableView dequeueReusableCellWithIdentifier:kLYQMineTopicManageNumberCell_ID forIndexPath:indexPath];
        
        return cell;
    }

}

#pragma mark 设置cell可编辑
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        return YES;
    }
    
    return NO;
}

#pragma mark 设置cell编辑样式
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewCellEditingStyleDelete;
}

#pragma mark 设置cell编辑事件
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView setEditing:NO animated:YES];
    
    //TODO:删除一条数据
    NSLog(@"呵呵== %ld%ld",indexPath.section,indexPath.row);
    
}

#pragma mark 设置删除title
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
    return @"删除";
}

#pragma mark - tableview delegate
#pragma mark 单元格点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    NSLog(@"点击section=%ld",indexPath.section);
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.0001f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return kWScale(10);
}

#pragma mark 设置分割线偏移量
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsMake(0, 0, 0, 0)];
    }
}


#pragma mark - 内存警告
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
